var newvue = new Vue({
	el: "body",
	data: {
		shop: [],
		cla: [],
		address:"",
		shopid:"",
		shows:false,
		isa:false,
		isb:false
	},
	methods: {
		show: function(index) {
			location.href="shop/shop.html?shopId="+this.shop[index].id
		},
		claa:function(bigInde,index){
			location.href="buy.class/buy.class.html?class="+this.cla[bigInde][index]
		},
		querys:function(){
              query()
		},
		clik:function(){
			this.isa=true;
			this.isb=false;
			this.shows=true;
		},
		cliks:function(){
			this.isa=false;
			this.isb=true;
//			this.shows=false;
		}
	}
});
get()

	function get() {
	var APP_ID = 'c4w6bVvWfh8xxcmkBE1G0gIt-gzGzoHsz';
	var APP_KEY = 'JBikg4Ksk76zcTi5BKYWvTJF';
	AV.init({
		appId: APP_ID,
		appKey: APP_KEY
	});
	var arr = [];
	var query = new AV.Query('ELM_shop');
	query.include('owner');
	query.descending('createdAt');
	query.find().then(function(products) {
		//		console.log(products)
		for(var i = 0; i < products.length; i++) {
			var jop = {
				id: products[i].id,
				shopname: products[i].attributes.shopname,
				shophours: products[i].attributes.shophours,
				startprice: products[i].attributes.startprice,
				classify: products[i].attributes.classify,
				productclassify: products[i].attributes.productclassify,
				adress: products[i].attributes.adress,
				attr1: products[i].attributes.attr1,
				attr2: products[i].attributes.attr2,
				attr3: products[i].attributes.attr3,
				grade: products[i].attributes.grade,
				notice: products[i].attributes.notice,
				salenum: products[i].attributes.salenum,
				sendprice: products[i].attributes.sendprice,
				shophours: products[i].attributes.shophours,
				shopimg: products[i].attributes.shopimg,
			}
			newvue.shop.push(jop);
			//			console.log(products[i].attributes.classify)
			arr.push(products[i].attributes.classify)
		}
		var arrs = arr.join();
		var arra = arrs.split(",");
		var arras = []
		for(var i = 0; i < arra.length; i++) {
			if(arras.indexOf(arra[i]) == -1) {
				arras.push(arra[i])
			}
		}

		var a = [];
		for(var h = 0; h < arras.length; h++) {
			a.push(arras[h])
			if((h + 1) % 8 == 0 || h == arras.length - 1) {
				newvue.cla.push(a);
				a = [];
			}
		}
		newvue.$nextTick(function() {
			var swiper = new Swiper('.swiper-container', {
				pagination: '.swiper-pagination',
				paginationClickable: true
			});
		})
	}).catch(function(error) {
		alert(JSON.stringify(error));
	});
}

function query() {
	var query = new AV.Query('ELM_shop');
	query.contains('shopname', newvue.shopid);
	query.find().then(function(todo) {
		location.href = "shop/shop.html?shopId="+todo[0].id
	}, function(error) {
		// 异常处理
	});
}